<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input v-model="toDoMsg">
        <button @click="appendMsgToList">添加</button>
        <p v-for="(item,index) in toDoList" :key="index">
            <span>{{item}}</span>
        </p>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <script>
        new Vue({
            el:'#app',
            data:{
                toDoMsg:'',
                toDoList:[]
            },
            methods:{
                appendMsgToList(){
                    if(this.toDoMsg){
                        this.toDoList.push(this.toDoMsg);
                    }
                }
            },
        })
    </script>
</body>
</html>